package com.wasion.pwportable.protocol.analyzer.indicator;

import java.util.ArrayList;
import java.util.List;

import com.wasion.pwportable.protocol.analyzer.AbstractAnalyzer;

/**
 * 
 * @ClassName: Load_Current_Analyzer
 * @Description: 架空型故障指示器负荷电流数据记录 C6 C7 C8 C9
 * @author 高意
 * @date 2014-9-10 下午4:54:29
 * 
 */
public class Load_Current_Analyzer extends AbstractAnalyzer {

	@Override
	public void dataAnalysis(String ackBS) {

		List<Double> currents = new ArrayList<Double>();

		if (Integer.parseInt(ackBS.substring(2, 4), 16) == 10) {
			if ("E1".equalsIgnoreCase(ackBS.substring(22, 24))) {
				result.setDataFlag(1);
			} else if ("EE".equalsIgnoreCase(ackBS.substring(22, 24))) {
				result.setDataFlag(2);
			}
			return;
		} else {
			for (int i = 22; i < ackBS.length() - 4; i += 4) {
				String laoddata = ackBS.substring(i + 2, i + 4)
						+ ackBS.substring(i, i + 2);
				double load = getCurrentInverted(laoddata);
				currents.add(load);
			}
		}

		result.setCurrentData(currents);
	}
}
